package lab02.test06;

public class Triangle {

    double firstside;
    double secondside;
    double thirdside;
    double area;
    double perimeter;

    public void setSide1(double side1) {
        this.firstside = side1;
    }

    public void setSide2(double side2) {
        this.secondside = side2;
    }

    public void setSide3(double side3) {
        this.thirdside = side3;
    }

    public double getSide1() {
        return firstside;
    }

    public double getSide2() {
        return secondside;
    }
    public double getSide3() {
        return thirdside;
    }
    public double getArea() {
        double p = (firstside + secondside + thirdside) / 2;
        area = Math.sqrt(p * (p - firstside) * (p - secondside) * (p - thirdside));//海伦公式
        return area;
    }
    public double getPerimeter() {
        perimeter = firstside + secondside + thirdside;
        return perimeter;
    }
    public void changeSide(double side1, double side2, double side3) {
        this.firstside = side1;
        this.secondside = side2;
        this.thirdside = side3;
    }
    public void setNewSide1(double side1) {
        this.firstside = side1;
    }
    public void setNewSide2(double side2) {
        this.secondside = side2;
    }
    public void setNewSide3(double side3) {
        this.thirdside = side3;
    }
    public double getNewSide1() {
        return firstside;
    }
    public double getNewSide2() {
        return secondside;
    }
    public double getNewSide3() {
        return thirdside;
    }
    public boolean judgeSide() {
        if (firstside + secondside > thirdside && thirdside + secondside > firstside && firstside + thirdside > secondside & firstside - secondside < thirdside && thirdside - secondside < firstside && firstside - thirdside < secondside) {
            return true;
        } else {
            return false;
        }
    }
}